#include "MainForm.h"
#include <qdebug.h>
#include "CDlgSetupRef.h"
#include "CDlgSetupRefMatrix.h"
#include "CDlgSetupADChan.h"
#include "nti_global.h"

MainForm::MainForm(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);
	connect(ui.actionSet_Reference, &QAction::triggered, this, &MainForm::on_actionSet_Reference);
	connect(ui.actionSet_RefMat, &QAction::triggered, this, &MainForm::on_actionSet_Refmatrix);
	connect(ui.actionSet_ADChan, &QAction::triggered, this, &MainForm::on_actionSet_ADChan);

}

void MainForm::on_actionSet_Reference()
{
	qDebug() << "setup Reference";
	CDlgSetupRef dlg(this);
	dlg.resize(1600, 800);
	if (dlg.exec() == QDialog::Accepted)
	{
		::g_listRefPSD = dlg.m_listRefPSD;
		::g_listRefCoh = dlg.m_listRefCoh;
		::g_listRefPhi = dlg.m_listRefPhi;
		::g_nCtrl = dlg.m_nCtrl;
		::g_szUnitsAcc = dlg.m_szUnitAcc;
	}
}

void MainForm::on_actionSet_Refmatrix()
{
	CDlgSetupRefMatrix dlg(this);
	dlg.m_listRefPSD = ::g_listRefPSD;
	dlg.m_listRefCoh = ::g_listRefCoh;
	dlg.m_listRefPhi = ::g_listRefPhi;
	dlg.m_nCtrl = ::g_nCtrl;

	dlg.resize(1600, 800);
	if (dlg.exec() == QDialog::Accepted)
	{
		::g_listRefPSD = dlg.m_listRefPSD; // update nMatDiagIndex
		//::g_listRefCoh = dlg.m_listRefCoh;
		//::g_listRefPhi = dlg.m_listRefPhi;
	}
}

void MainForm::on_actionSet_ADChan()
{
	CDlgSetupADChan dlg(this);
	dlg.resize(1600, 800);
	dlg.m_listRefPSD = ::g_listRefPSD;
	dlg.m_nCtrl = ::g_nCtrl;
	dlg.m_szUnitsAcc = ::g_szUnitsAcc;
	if (dlg.exec() == QDialog::Accepted)
	{
		::g_mapADChan = dlg.m_mapADChan;
	}
}



